:root {
  --ink: #112234;
  --muted: #6f7f8f;
  --navy: #081a2b;
  --navy-2: #102d47;
  --teal: #19a89d;
  --teal-dark: #0e8179;
  --sky: #dff5f2;
  --amber: #f5b942;
  --red: #d95855;
  --green: #16866f;
  --line: #dfe6ea;
  --canvas: #f3f6f7;
  --white: #ffffff;
  --shadow: 0 12px 32px rgba(24, 50, 70, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar { min-height: 78px; padding: 14px 26px; color: white; background: var(--navy); display: flex; align-items: center; justify-content: space-between; gap: 24px; position: sticky; top: 0; z-index: 20; box-shadow: 0 8px 22px rgba(2, 17, 29, .16); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.25); border-radius: 11px; position: relative; transform: rotate(45deg); background: linear-gradient(135deg, rgba(25,168,157,.35), transparent); }
.brand-mark span { position: absolute; width: 22px; height: 3px; background: var(--teal); top: 19px; left: 9px; border-radius: 4px; }
.brand-mark i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); right: 7px; top: 17px; }
.eyebrow { margin: 0 0 3px; letter-spacing: .12em; font-size: 10px; font-weight: 800; color: var(--teal-dark); text-transform: uppercase; }
.topbar .eyebrow { color: #75d1ca; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(18px, 2vw, 24px); line-height: 1.15; letter-spacing: -.02em; }
h1 span { color: #a9babf; font-weight: 500; }
h2 { margin-bottom: 7px; font-size: 24px; line-height: 1.2; letter-spacing: -.03em; }
h3 { margin: 0; font-size: 16px; letter-spacing: -.015em; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.privacy { display: inline-flex; align-items: center; gap: 7px; color: #c6d4dc; font-size: 12px; margin-right: 8px; }
.privacy i { width: 7px; height: 7px; border-radius: 50%; background: #55d6a9; box-shadow: 0 0 0 4px rgba(85,214,169,.12); }
.button { border: 1px solid transparent; border-radius: 9px; padding: 9px 13px; font-weight: 700; font-size: 12px; }
.button.secondary { color: var(--navy); background: white; }
.button.ghost { color: white; background: transparent; border-color: #496075; }

.shell { min-height: calc(100vh - 78px); display: grid; grid-template-columns: 330px minmax(0, 1fr); }
.assumptions { position: sticky; top: 78px; height: calc(100vh - 78px); overflow-y: auto; padding: 22px 20px 32px; background: #fff; border-right: 1px solid var(--line); }
.aside-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.aside-head h2 { font-size: 19px; }
.draft-badge { padding: 4px 8px; border-radius: 20px; color: #8a5e00; background: #fff3d6; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.scenario-tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin: 13px 0 7px; padding: 3px; border-radius: 10px; background: #edf2f4; }
.scenario-tab { padding: 8px 5px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; }
.scenario-tab.active { color: white; background: var(--navy-2); box-shadow: 0 3px 9px rgba(16,45,71,.18); }
.scenario-toolbar { min-height: 25px; display: flex; align-items: center; justify-content: space-between; font-size: 10px; color: var(--muted); }
.text-button { border: 0; padding: 3px; color: var(--teal-dark); background: none; font-weight: 800; font-size: 10px; }
.input-group { border-top: 1px solid var(--line); }
.input-group:last-child { border-bottom: 1px solid var(--line); }
.group-toggle { width: 100%; padding: 12px 0; border: 0; background: transparent; display: flex; align-items: center; justify-content: space-between; color: var(--ink); font-weight: 800; font-size: 12px; }
.group-toggle:after { content: '+'; font-size: 17px; color: var(--muted); font-weight: 400; }
.input-group.open .group-toggle:after { content: '−'; }
.group-fields { display: none; grid-template-columns: 1fr 1fr; gap: 11px 10px; padding: 0 0 15px; }
.input-group.open .group-fields { display: grid; }
.field { display: grid; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { min-height: 28px; color: #526372; font-size: 10px; font-weight: 700; line-height: 1.2; }
.input-wrap { display: flex; align-items: center; border: 1px solid #cfd9de; border-radius: 8px; background: #fbfcfc; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.input-wrap:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(25,168,157,.11); background: white; }
.input-wrap input { width: 100%; min-width: 0; border: 0; outline: none; background: transparent; padding: 8px 6px 8px 9px; color: var(--ink); font-weight: 750; font-size: 12px; }
.input-wrap span { flex: 0 0 auto; padding-right: 8px; color: #84919d; font-size: 9px; font-weight: 700; }
.model-note { margin-top: 18px; padding: 12px; border-left: 3px solid var(--teal); border-radius: 3px 9px 9px 3px; background: #f0f9f8; font-size: 10px; color: #57706e; }
.model-note strong { color: var(--teal-dark); }
.model-note p { margin: 4px 0 0; }

.workspace { min-width: 0; padding: 0 26px 42px; }
.view-tabs { position: sticky; top: 78px; z-index: 10; display: flex; gap: 22px; padding: 16px 0 10px; background: rgba(243,246,247,.96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.view-tab { border: 0; border-bottom: 2px solid transparent; padding: 5px 0 9px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; }
.view-tab.active { color: var(--navy); border-color: var(--teal); }
.view { display: none; padding-top: 24px; }
.view.active { display: block; }
.hero-row, .section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 19px; }
.summary { max-width: 760px; margin: 0; color: var(--muted); }
.hero-status { text-align: right; }
.hero-status small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.decision-badge { display: inline-block; border-radius: 20px; padding: 6px 10px; font-size: 11px; font-weight: 850; }
.decision-badge.positive { color: #096d57; background: #d9f4e9; }
.decision-badge.watch { color: #8a5e00; background: #fff1ce; }
.decision-badge.negative { color: #a33434; background: #ffe1df; }

.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric-card { min-height: 118px; padding: 15px; border: 1px solid #e1e7ea; border-radius: 13px; background: white; box-shadow: 0 5px 15px rgba(35,62,81,.035); position: relative; overflow: hidden; }
.metric-card:after { content: ''; position: absolute; right: -18px; bottom: -24px; width: 60px; height: 60px; border-radius: 50%; background: var(--sky); }
.metric-label { min-height: 28px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.metric-value { margin: 7px 0 3px; color: var(--navy); font-size: clamp(18px, 2vw, 26px); font-weight: 850; line-height: 1; letter-spacing: -.045em; }
.metric-foot { color: #8b989f; font-size: 9px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.panel { background: white; border: 1px solid #e0e7ea; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-12 { grid-column: span 12; }
.panel-head { display: flex; align-items: start; justify-content: space-between; gap: 15px; padding: 17px 18px 10px; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; color: var(--muted); font-size: 9px; }
.legend span:before { content: ''; width: 7px; height: 7px; border-radius: 2px; display: inline-block; margin-right: 5px; }
.legend .rev:before { background: var(--teal); }
.legend .ebitda:before { background: var(--navy-2); }
.legend .debt:before { background: var(--amber); }
.threshold { color: var(--muted); font-size: 9px; font-weight: 700; }
.subtle { color: var(--muted); font-size: 10px; }
.chart { min-height: 250px; padding: 3px 12px 12px; }
.chart.compact { min-height: 250px; }
.chart svg { width: 100%; height: 250px; display: block; overflow: visible; }
.chart text { font: 9px Inter, sans-serif; fill: #7b8993; }
.chart .grid { stroke: #e8edef; stroke-width: 1; }
.chart .axis { stroke: #cbd5da; stroke-width: 1; }
.chart .threshold-line { stroke: var(--amber); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { opacity: .1; }

.table-scroll { overflow: auto; }
.table-scroll.tall { max-height: calc(100vh - 250px); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px; white-space: nowrap; }
.data-table th { position: sticky; top: 0; z-index: 2; padding: 10px 12px; text-align: right; color: #6e7b85; background: #f6f8f9; border-top: 1px solid #e8edef; border-bottom: 1px solid #e1e7ea; font-size: 9px; text-transform: uppercase; letter-spacing: .04em; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table td { padding: 11px 12px; text-align: right; border-bottom: 1px solid #edf1f2; }
.data-table tbody tr { transition: background .15s; }
.comparison tbody tr { cursor: pointer; }
.comparison tbody tr:hover, .comparison tbody tr.active { background: #f0f9f8; }
.comparison .scenario-name { font-weight: 850; }
.comparison .active .scenario-name:after { content: 'ACTIVE'; margin-left: 8px; padding: 3px 5px; color: var(--teal-dark); background: #d9f2ef; border-radius: 4px; font-size: 8px; }
.cashflow th:first-child, .cashflow td:first-child { position: sticky; left: 0; z-index: 1; background: white; box-shadow: 1px 0 0 #e4eaed; }
.cashflow th:first-child { z-index: 3; background: #f6f8f9; }
.cashflow .operation td { background: #f9fbfb; }
.cashflow .total td { font-weight: 850; color: var(--navy); }
.cashflow .negative { color: var(--red); }
.inline-totals { display: flex; gap: 10px; }
.inline-totals span { padding: 7px 9px; border-radius: 7px; background: white; border: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.inline-totals strong { color: var(--ink); }
.checks-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 14px; }
.check { padding: 14px; border-radius: 11px; background: white; border: 1px solid var(--line); }
.check-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 11px; }
.check-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(22,134,111,.1); }
.check.fail .check-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(217,88,85,.1); }
.check p { margin: 7px 0 0; color: var(--muted); font-size: 9px; }

.metric-select { display: grid; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.metric-select select { min-width: 140px; padding: 8px 9px; color: var(--ink); border: 1px solid #cfd9de; border-radius: 8px; background: white; font-weight: 700; text-transform: none; }
.tornado { padding: 10px 18px 20px; }
.tornado-row { display: grid; grid-template-columns: 108px 1fr; align-items: center; gap: 9px; margin: 13px 0; }
.tornado-label { color: #50616f; font-size: 10px; font-weight: 750; text-align: right; }
.tornado-track { height: 23px; background: linear-gradient(90deg, #f7f8f9 49.7%, #cbd5da 50%, #f7f8f9 50.3%); position: relative; border-radius: 4px; }
.tornado-bar { position: absolute; top: 3px; height: 17px; border-radius: 3px; min-width: 2px; }
.tornado-bar.low { right: 50%; background: #df7772; border-radius: 3px 0 0 3px; }
.tornado-bar.high { left: 50%; background: var(--teal); border-radius: 0 3px 3px 0; }
.tornado-value { position: absolute; top: 4px; font-size: 8px; font-weight: 850; white-space: nowrap; }
.tornado-value.low { right: calc(50% + 4px); color: #a13d39; }
.tornado-value.high { left: calc(50% + 4px); color: #08776f; }
.matrix-wrap { padding: 8px 18px 20px; overflow: auto; }
.matrix { width: 100%; border-collapse: separate; border-spacing: 4px; font-size: 10px; text-align: center; }
.matrix th { color: var(--muted); font-weight: 750; font-size: 9px; }
.matrix td { min-width: 62px; height: 42px; border-radius: 6px; color: white; font-weight: 850; }
.matrix td.active-cell { outline: 3px solid var(--navy); outline-offset: 1px; }
.axis-title { color: var(--teal-dark) !important; }
.insights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 4px 18px 19px; }
.insight { padding: 14px; border-radius: 10px; background: #f6f9f9; border-left: 3px solid var(--teal); }
.insight.warn { border-left-color: var(--amber); }
.insight.risk { border-left-color: var(--red); }
.insight strong { display: block; margin-bottom: 4px; font-size: 11px; }
.insight p { margin: 0; color: var(--muted); font-size: 10px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; padding: 10px 14px; border-radius: 8px; color: white; background: var(--navy); box-shadow: 0 8px 25px rgba(5,22,36,.25); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s; font-size: 11px; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1180px) {
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
  .shell { grid-template-columns: 300px minmax(0,1fr); }
  .span-5, .span-7 { grid-column: span 12; }
}

@media (max-width: 780px) {
  .topbar { position: relative; padding: 14px 16px; align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .privacy { width: 100%; justify-content: flex-end; }
  .shell { display: block; }
  .assumptions { position: relative; top: 0; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace { padding: 0 14px 30px; }
  .view-tabs { top: 0; overflow-x: auto; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .checks-grid, .insights { grid-template-columns: 1fr 1fr; }
  .hero-row, .section-head { align-items: flex-start; flex-direction: column; }
  .hero-status { text-align: left; }
  .brand h1 span { display: block; }
}

@media (max-width: 500px) {
  .brand-mark { display: none; }
  .topbar { display: block; }
  .top-actions { margin-top: 12px; justify-content: flex-start; }
  .privacy { width: auto; margin-right: auto; justify-content: flex-start; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 110px; }
  .checks-grid, .insights { grid-template-columns: 1fr; }
  .input-groups .group-fields { grid-template-columns: 1fr 1fr; }
}
